﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using MaxStudio.Concrete.DBUtility;
using MaxStudio.Concrete.Server.Dao;
using MaxStudio.Concrete.Server.Interface;

namespace MaxStudio.Concrete.Server.Service
{
    public class RPTAdmixtureAllocateService : ServiceHandle, IRPTAdmixtureAllocate
    {
        #region IRPTAdmixtureAllocate Members

        public OperationResult<List<tb_RPT_AdmixtureAllocate>> GetAllAdmixtureAllocate()
        {
            OperationResult<List<tb_RPT_AdmixtureAllocate>> result = new OperationResult<List<tb_RPT_AdmixtureAllocate>>();
            List<tb_RPT_AdmixtureAllocate> list = new List<tb_RPT_AdmixtureAllocate>();
            ConcreteDaoDataContext dataContext = getDateContext();
            try
            {
                list = dataContext.GetAllAdmixtureAllocate();
                if (list == null)
                {
                    result.errorMessageKey = "Error";
                }
                else
                {
                    result.obj = list;
                    result.operationSuccess = true;
                }
            }
            catch (Exception ex)
            {
                result.exceptionString = DlHelper.ExceptionString(ex);

            }
            return result;
        }

        public OperationResult<List<tb_RPT_AdmixtureAllocate>> GetAdmixtureAllocateByAllocateDate(DateTime allocateDate)
        {
            OperationResult<List<tb_RPT_AdmixtureAllocate>> result = new OperationResult<List<tb_RPT_AdmixtureAllocate>>();
            List<tb_RPT_AdmixtureAllocate> list = new List<tb_RPT_AdmixtureAllocate>();
            ConcreteDaoDataContext dataContext = getDateContext();
            try
            {
                list = dataContext.GetAdmixtureAllocateByAllocateDate(allocateDate);
                if (list == null)
                {
                    result.errorMessageKey = "Error";
                }
                else
                {
                    result.obj = list;
                    result.operationSuccess = true;
                }
            }
            catch (Exception ex)
            {
                result.exceptionString = DlHelper.ExceptionString(ex);

            }
            return result;
        }

        public OperationResult<List<tb_RPT_AdmixtureAllocate>> GetAdmixtureAllocateByAllocateDate(DateTime allocateDate1, DateTime allocateDate2)
        {
            OperationResult<List<tb_RPT_AdmixtureAllocate>> result = new OperationResult<List<tb_RPT_AdmixtureAllocate>>();
            List<tb_RPT_AdmixtureAllocate> list = new List<tb_RPT_AdmixtureAllocate>();
            ConcreteDaoDataContext dataContext = getDateContext();
            try
            {
                list = dataContext.GetAdmixtureAllocateByAllocateDate(allocateDate1, allocateDate2);
                if (list == null)
                {
                    result.errorMessageKey = "Error";
                }
                else
                {
                    result.obj = list;
                    result.operationSuccess = true;
                }
            }
            catch (Exception ex)
            {
                result.exceptionString = DlHelper.ExceptionString(ex);

            }
            return result;
        }

        public OperationResult<List<tb_RPT_AdmixtureAllocate>> GetAdmixtureAllocateByContition(string strAllocateDate, string strPowdeDosage
                                                                                            , string strLiquidWeight, string strTankNumber
                                                                                            , string strCreateDate)
        {
            OperationResult<List<tb_RPT_AdmixtureAllocate>> result = new OperationResult<List<tb_RPT_AdmixtureAllocate>>();
            List<tb_RPT_AdmixtureAllocate> list = new List<tb_RPT_AdmixtureAllocate>();
            ConcreteDaoDataContext dataContext = getDateContext();
            try
            {
                list = dataContext.GetAdmixtureAllocateByContition(strAllocateDate, strPowdeDosage, strLiquidWeight, strTankNumber, strCreateDate);
                if (list == null)
                {
                    result.errorMessageKey = "Error";
                }
                else
                {
                    result.obj = list;
                    result.operationSuccess = true;
                }
            }
            catch (Exception ex)
            {
                result.exceptionString = DlHelper.ExceptionString(ex);

            }
            return result;
        }

        public OperationResult<tb_RPT_AdmixtureAllocate> GetAdmixtureAllocateById(int id)
        {
            ConcreteDaoDataContext dataContext = getDateContext();
            OperationResult<tb_RPT_AdmixtureAllocate> result = new OperationResult<tb_RPT_AdmixtureAllocate>();
            tb_RPT_AdmixtureAllocate admixtureAllocate;
            try
            {
                admixtureAllocate = dataContext.GetAdmixtureAllocateById(id);
                if (admixtureAllocate == null)
                {
                    result.errorMessageKey = "Error";
                }
                else
                {
                    result.obj = admixtureAllocate;
                    result.operationSuccess = true;
                }
            }
            catch (Exception ex)
            {
                result.exceptionString = DlHelper.ExceptionString(ex);

            }
            return result;
        }

        public OperationResult<tb_RPT_AdmixtureAllocate> CreateAdmixtureAllocate(tb_RPT_AdmixtureAllocate entity)
        {
            OperationResult<tb_RPT_AdmixtureAllocate> result = new OperationResult<tb_RPT_AdmixtureAllocate>();
            ConcreteDaoDataContext dataContext = getDateContext();
            try
            {
                dataContext.CreateAdmixtureAllocate(entity);
                dataContext.SubmitChanges();
                result.obj = entity;
                result.operationSuccess = true;
            }
            catch (Exception ex)
            {
                result.exceptionString = DlHelper.ExceptionString(ex);
            }

            return result;
        }

        public OperationResult<tb_RPT_AdmixtureAllocate> ModifyAdmixtureAllocate(tb_RPT_AdmixtureAllocate entity)
        {
            OperationResult<tb_RPT_AdmixtureAllocate> result = new OperationResult<tb_RPT_AdmixtureAllocate>();
            ConcreteDaoDataContext dataContext = getDateContext();
            try
            {
                dataContext.ModifyAdmixtureAllocate(entity);
                dataContext.SubmitChanges();
                result.obj = entity;
                result.operationSuccess = true;
            }
            catch (Exception ex)
            {
                result.exceptionString = DlHelper.ExceptionString(ex);
            }

            return result;
        }

        public OperationResult<tb_RPT_AdmixtureAllocate> DeleteAdmixtureAllocate(tb_RPT_AdmixtureAllocate entity)
        {
            OperationResult<tb_RPT_AdmixtureAllocate> result = new OperationResult<tb_RPT_AdmixtureAllocate>();
            ConcreteDaoDataContext dataContext = getDateContext();
            try
            {
                dataContext.DeleteAdmixtureAllocate(entity);
                dataContext.SubmitChanges();
                result.obj = entity;
                result.operationSuccess = true;
            }
            catch (Exception ex)
            {
                result.exceptionString = DlHelper.ExceptionString(ex);
            }

            return result;
        }

        #endregion
    }
}
